package org.hy.pay.common.core.exception;

public class BizException extends RuntimeException{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	public static final BizException DB_INSERT_RESULT_0 = new BizException(10040001,"数据库操作,insert返回0");
	public static final BizException DB_UPDATE_RESULT_0 = new BizException(10040002,"数据库操作,update返回0");
	public static final BizException DB_SELECT_IS_NULL = new BizException(10040003,"数据库操作，selectOne 返回nulll");
	public static final BizException DB_LIST_IS_NULL = new BizException(10040004,"数据库操作,list返回null");
	public static final BizException TOKEN_IS_ILLICIT = new BizException(10040005,"Toek 校验非法");
	public static final BizException SESSION_IS_OUT_TIME = new BizException(10040006,"会话超时");
	public static final BizException DB_GET_SEQ_NEXT_VALUE_ERROR = new BizException(10040007,"生成序列超时");

	/**
	 * 异常消息
	 */
	protected String msg;
	/**
	 * 异常代码
	 */
	protected int code;
	
	public BizException(){
		super();
	}
	
	public BizException(String message,Throwable cause){
		super(message,cause);
	}
	
	public BizException(Throwable cause){
		super(cause);
	}
	public BizException(int code,String msgFortmat,Object... args){
		super(String.format(msgFortmat, args));
		this.code = code;
		this.msg = String.format(msgFortmat, args);
	}
	
	
	
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	public BizException newInstance(String msgFortmat ,String msg){
		return new BizException(this.code,msgFortmat,msg);
	}

	public static void main(String[] args) {
		/*BizException biz = new BizException(0,"数据库操作,insert返回0.{%s}","张三的哥哥").newInstance(11, "9999999");
		System.out.println(biz.code);
		System.out.println(biz.msg);*/
		/*BizException.db
		BizException biz = BizException.DB_INSERT_RESULT_0.newInstance("数据库操作,insert返回0.{%s}", "000000000000000000000000");
		System.out.println(biz.code);
		System.out.println(biz.msg);*/
	}
}
